package com.github.dice.init;

import javax.annotation.Resource;

import com.github.dice.service.IPlayerService;
import com.github.dice.service.IRoomOwnerService;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import com.github.dice.entity.Player;
import com.github.dice.entity.RoomOwner;

@Component
@Order(value = 1)
public class InitData implements ApplicationRunner {

    @Resource
    private IPlayerService playerService;

    @Resource
    private IRoomOwnerService roomOwnerService;

    @Override
    public void run(ApplicationArguments var1) throws Exception {
        createPlayerData();
        createRoomOwnerData();
    }

    public void createPlayerData() {
        for (Player player : PlayerData.players) {
            playerService.addPlayer(player);
        }
    }

    public void createRoomOwnerData() {
        for (RoomOwner roomOwner : RoomOwnerData.roomOwners) {
            roomOwnerService.addRoomOwner(roomOwner);
        }
    }
}
